package com.lucy.nepu.module.topic.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.lucy.common.converter.JpaColumnConverter;
import com.lucy.common.core.BaseEntity;
import com.lucy.nepu.module.topic.converter.ExtParamsConverter;
import com.lucy.nepu.module.topic.model.ExtParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import javax.persistence.Column;
import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * @author kindear
 * 纵向课题实体类
 */
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@Entity
@Table(name = "nepu_topic")
@ApiModel(value = "纵向课题")
public class Topic extends BaseEntity implements Serializable {
    @ApiModelProperty("周期ID")
    @Column(name = "period_id")
    String periodId;

    /**
     * 课题编码
     */
    @ApiModelProperty("课题编码")
    @Column(name = "topic_code")
    String topicCode;

    @ApiModelProperty(value = "纵向课题名称",notes = "")
    @Column(name = "topic_name")
    String topicName;

    @ApiModelProperty(value = "课题词典ID",notes = "")
    @Column(name = "topic_dict_id")
    String topicDictId;

    @ApiModelProperty("课题经费")
    @Column(name = "topic_funds",scale = 2)
    Double topicFunds;

    @ApiModelProperty("已到账经费")
    @Column(name = "reveived_funds",scale = 2)
    Double receivedFunds;
    /**
     * 纵向课题负责人姓名
     */
    @ApiModelProperty(value = "纵向课题负责人",notes = "")
    @Column(name = "leader")
    String leader;

    /**
     * 纵向课题负责人ID
     */
    @ApiModelProperty(value = "纵向课题负责人ID",notes = "")
    @Column(name = "leader_id")
    Long leaderId;

    /**
     * 纵向课题成员ID列表
     */
    @ApiModelProperty(value = "纵向课题成员ID列表",notes = "")
    @Convert(converter = JpaColumnConverter.class)
    @Column(name = "user_id_list")
    List<Long> userIdList;




    /**
     * 纵向课题开始日期
     */
    @ApiModelProperty(value = "课题立项日期",notes = "课题立项日期，如2021/11/16")
    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
    @Column(name = "start_date")
    Date startDate;

    /**
     * 纵向课题完成日期
     */
    @ApiModelProperty(value = "课题结项日期",notes = "课题结项日期，如2021/11/16")
    @JsonFormat(pattern="yyyy-MM-dd",timezone = "GMT+8")
    @Column(name = "end_date")
    Date endDate;

    /**
     * 分配所得工作量
     */
    @ApiModelProperty(value = "工作量",notes = "")
    @Column(name = "workload",scale = 2)
    Double workload;


    @Convert(converter = ExtParamsConverter.class)
    @ApiModelProperty("拓展参数")
    @Column(name = "ext_params")
    ExtParams extParams;


    /**
     * 0. 关闭状态 -- 可以删除
     * 1. 正常状态 -- 可以删除
     * 2. 已经登记工作量 -- 锁定无法操作
     */
    @ApiModelProperty("记录状态")
    @Column(name = "status")
    Integer status;

    @NotEmpty(message = "关联文件不可为空")
    @Convert(converter = JpaColumnConverter.class)
    @ApiModelProperty(value = "关联文件ID列表")
    List<String> fileIds;



}
